import request from '@/config/axios'

// 消耗型物资 VO
export interface AssetsConsumableVO {
  id: number // 编号
  catetoryId: number // 分类ID
  name: string // 物资名称
  specification: string // 规格型号
  unitPrice: number // 单价
  unit: string // 计量单位
  sort: number // 排序
  status: number // 状态
  remark: string // 备注
  inRemark: string //补货说明
  userIds: string //领用人
  price: number //单价
  stockQuantity: number //库存数量
  borrowedQuantity: number //领用数量
  remindCount: number //预警数量
}

// 消耗型物资 API
export const AssetsConsumableApi = {
  // 查询消耗型物资分页
  getAssetsConsumablePage: async (params: any) => {
    return await request.get({ url: `/school/assets-consumable/page`, params })
  },

  // 查询消耗型物资库存预警分页
  getAssetsConsumableRemindWarningPage: async (params: any) => {
    return await request.get({ url: `/school/assets-consumable/page-remind-warning`, params })
  },

  // 查询消耗型物资详情
  getAssetsConsumable: async (id: number) => {
    return await request.get({ url: `/school/assets-consumable/get?id=` + id })
  },

  // 查询物资分类分组统计数量
  getAssetsConsumableReportByType: async () => {
    return await request.get({ url: `/school/assets-consumable/report-by-type` })
  },

  // 根据物资流转分组统计数量
  getAssetsConsumableReportByFlow: async () => {
    return await request.get({ url: `/school/assets-consumable/report-by-flow` })
  },

  /**
   * 根据年份统计数量
   * @param {string} year 年份
   * @returns
   */
  getAssetsConsumableReportByYear: async (year) => {
    return await request.get({ url: `/school/assets-consumable/report-by-year?year=${year}` })
  },

  // 新增消耗型物资
  createAssetsConsumable: async (data: AssetsConsumableVO) => {
    return await request.post({ url: `/school/assets-consumable/create`, data })
  },

  // 修改消耗型物资
  updateAssetsConsumable: async (data: AssetsConsumableVO) => {
    return await request.put({ url: `/school/assets-consumable/update`, data })
  },

  //领用， 补货等操作
  operAssetsConsumable: async (data: AssetsConsumableVO) => {
    return await request.put({ url: `/school/assets-consumable/oper`, data })
  },

  // 删除消耗型物资
  deleteAssetsConsumable: async (id: number) => {
    return await request.delete({ url: `/school/assets-consumable/delete?id=` + id })
  },

  // 导出消耗型物资 Excel
  exportAssetsConsumable: async (params) => {
    return await request.download({ url: `/school/assets-consumable/export-excel`, params })
  }
}
